unit uFDualListBox;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TFDualList = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    listBoxLeft: TListBox;
    listBoxRight: TListBox;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    OK : boolean;
  end;

var
  FDualList: TFDualList;

implementation

{$R *.dfm}

procedure TFDualList.Button1Click(Sender: TObject);
begin
  Close;
end;

procedure TFDualList.Button2Click(Sender: TObject);
begin
  OK := true;
  Close;
end;

procedure TFDualList.Button3Click(Sender: TObject);
begin
  if listBoxLeft.ItemIndex>-1 then
  begin
    listBoxRight.Items.Add(listBoxLeft.Items[listBoxLeft.ItemIndex]);
    listBoxLeft.Items.Delete(listBoxLeft.ItemIndex);
  end;
end;

procedure TFDualList.Button4Click(Sender: TObject);
begin
  while listBoxLeft.Items.Count>0 do begin
    listBoxRight.Items.Add(listBoxLeft.Items[0]);
    listBoxLeft.Items.Delete(0);
  end;
end;

procedure TFDualList.Button5Click(Sender: TObject);
begin
  if listBoxRight.ItemIndex>-1 then
  begin
    listBoxLeft.Items.Add(listBoxRight.Items[listBoxRight.ItemIndex]);
    listBoxRight.Items.Delete(listBoxRight.ItemIndex);
  end;
end;

procedure TFDualList.Button6Click(Sender: TObject);
begin
  while listBoxRight.Items.Count>0 do begin
    listBoxLeft.Items.Add(listBoxRight.Items[0]);
    listBoxRight.Items.Delete(0);
  end;
end;

procedure TFDualList.FormShow(Sender: TObject);
begin
  OK := False;
end;

end.
